use crate::models::{ChatMessage, ProjectConfig, Role};
use anyhow::Result;
use serde_json::Value;
use std::path::PathBuf;

#[tokio::test]
async fn test_tool_read_file_chat() -> Result<()> {
    // Create test messages
    let messages = vec![
        ChatMessage {
            tool_call_id: None,
            role: Role::System,
            content: "项目的base路径:/Users/caozy/Documents/projects/lingyun/log_analysis_system/log_analysis_front\n这是一个vue3项目".to_string(),
        },
        ChatMessage {
            tool_call_id: None,
            role: Role::User,
            content: "参考`src/models/NodeModel.ts`中的定义方式，来创建关于User的模型".to_string(),
        }
    ];

    let project_config = Some(ProjectConfig {
        path: PathBuf::from(
            "/Users/caozy/Documents/projects/lingyun/log_analysis_system/log_analysis_front",
        ),
        handle_ext: Vec::<String>::new(),
        exclude_folders: None,
    });

    let result = super::chat(&messages, 0.0, &project_config).await;

    assert!(!result.is_err()); // This will be true since we're not mocking the actual API call
    println!("--test-chat-result--:{:?}", result);

    Ok(())
}
